<?php
final class Controller_Slide extends Controller_Security{
    protected function Acquiescent(){
        $data=Database::GetRows('select * from app_image where ID>=? and ID<=? order by ID asc',array(1,5));
        Template::Assign('File1',$data[0]['Path']);
        Template::Assign('File2',$data[1]['Path']);
        Template::Assign('File3',$data[2]['Path']);
        Template::Assign('File4',$data[3]['Path']);
        Template::Assign('File5',$data[4]['Path']);
        Template::Assign('URL1',$data[0]['URL']);
        Template::Assign('URL2',$data[1]['URL']);
        Template::Assign('URL3',$data[2]['URL']);
        Template::Assign('URL4',$data[3]['URL']);
        Template::Assign('URL5',$data[4]['URL']);
        Template::Assign('AlertContainerDisplaySwitch','none'); //警告容器
        Template::Assign('AlertContent','');                    //警告内容
        Template::Display('other/slide.html');
    }

    protected function Upload(){
        list($filename,$error)=array(NULL,NULL);
        $up=new Uploader('file');
        $up->Size=20481212300*12;
        $up->Path=$GLOBALS['ApplicationConfig']['Path']['UploadSlide'];
        $up->FileExtension=array('gif','jpg','png','bmp');
        $up->Execute();
        switch($up->ErrorCode){
            case Uploader::UPLOAD_ERR_OK:
                $filename=$up->Filename;
            break;
            case Uploader::UPLOAD_ERR_NO_FILE:
                $error='请上传文件。';
            break;
            case Uploader::UPLOAD_ERR_EXTENSION:
                $error='扩展名不正确。';
            break;
            case Uploader::UPLOAD_ERR_CUSTOM_SIZE:
                $error='文件大小不正确。';
            break;
            default:
                $error=$up->ErrorCode;
            break;
        }
        Template::Assign('Filename',$GLOBALS['ApplicationConfig']['Path']['URISlide'].'/'.$filename);
        Template::Assign('Error',$error);
        Template::Display('upload/callback.html');
    }

    protected function Edit(){
        Database::UpdateRowsByValue('app_image','ID','1',array('Path'=>$_POST['file1'],'URL'=>$_POST['url1']));
        Database::UpdateRowsByValue('app_image','ID','2',array('Path'=>$_POST['file2'],'URL'=>$_POST['url2']));
        Database::UpdateRowsByValue('app_image','ID','3',array('Path'=>$_POST['file3'],'URL'=>$_POST['url3']));
        Database::UpdateRowsByValue('app_image','ID','4',array('Path'=>$_POST['file4'],'URL'=>$_POST['url4']));
        Database::UpdateRowsByValue('app_image','ID','5',array('Path'=>$_POST['file5'],'URL'=>$_POST['url5']));
        Template::Assign('File1',$_POST['file1']);
        Template::Assign('File2',$_POST['file2']);
        Template::Assign('File3',$_POST['file3']);
        Template::Assign('File4',$_POST['file4']);
        Template::Assign('File5',$_POST['file5']);
        Template::Assign('URL1',$_POST['url1']);
        Template::Assign('URL2',$_POST['url2']);
        Template::Assign('URL3',$_POST['url3']);
        Template::Assign('URL4',$_POST['url4']);
        Template::Assign('URL5',$_POST['url5']);
        Template::Assign('AlertContainerDisplaySwitch','block'); //警告容器
        Template::Assign('AlertContent','修改成功。');            //警告内容
        Template::Display('other/slide.html');
    }
}
?>